﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<WebSite.Models.ProjectModel>" %>
<%@ Register src="../Shared/PageTool.ascx" tagname="PageTool" tagprefix="uc_PT" %>
<%@ Import Namespace="WebSite.Models" %>
<%@ Import Namespace="WebSite.App_Code" %>
<%@ Import Namespace="WebSite.App_Data" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Project
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <style type="text/css">
    
    .List
    {
         background-color:White;
    }
     
    .List .header td
    {
        border:2px solid #385D8A;
        border-left:none;
        white-space:nowrap;
        padding:10px;
        background-color:#4F81BD;
        color:White;
    }
    
     .List .body
     {
         cursor:pointer;
     }
    
    .List .body td
    {
        border:2px solid #385D8A;
        border-top:none;
        border-left:none;
        white-space:nowrap;
        padding:10px;
        
    }
    
    .List .header .first
    {
        border-left:2px solid #385D8A;
        white-space:nowrap;
        padding:10px;
    }
    
    .List .header .hiden
    {
        background-color:#595959;
    }
    
    .List .body .first
    {
        border-left:2px solid #385D8A;
        white-space:nowrap;
        padding:10px;
    }
    
    .List .header .space
    {
        background-color:White;
        border-top:none;
        border-bottom:none;
        white-space:nowrap;
        padding:10px;
        
    }
    
    .List .body .space
    {
        background-color:White;
        border-top:none;
        border-bottom:none;
        white-space:nowrap;
        padding:10px;
        
    }
    
     .List .selected
     {
         background-color:Gray;
         color:White;
     }
    
    </style>

    <script type="text/javascript">

        $(document).ready(function () {

        });

        function SelectPj(Tr) {

            $("tr:gt(0)", $("#QueryTable")).attr("class", "body");
            $(Tr).attr("class", "body selected");
            $("input[name=DeleteID]").val($(Tr).attr("Key"));
            
            if ($(Tr).attr("CanDelete") != "True")
                $("#btnDelete").show();
            else
                $("#btnDelete").hide();
        }

        function OnDelete(id) { Posting('<%=L_PageEvent.MD_Project_Delete %>', id); return confirm('将会删除该项目的所有信息，请确认。'); }

        function Posting(event, id) {
            $("#PostingEvent").val(event);
            $("#PostingID").val(id);
        }

    </script>
    <br />

`   <% Html.BeginForm(); %>

    <%=Html.HiddenFor(o => o.PostingEvent, new { id = "PostingEvent" })%>
    <%=Html.HiddenFor(o => o.PostingID, new { id = "PostingID" })%>

    <table>        
        <tr>
            <td>类别</td>
            <td><%=Html.DropDownListFor(o=>o.Q_PjCategory, Model.PjCategorySource) %></td>
            <td>类型</td>
            <td><%=Html.DropDownListFor(o => o.Q_PjType, Model.PjType)%></td>
        </tr>
        <tr>
            <td>编制单位</td>
            <td colspan="3"><%=Html.TextBoxFor(o=>o.Q_Department, new { @class = "budget-txt-no-01" })%></td>
            <td>项目负责人</td>
            <td colspan="3"><%=Html.TextBoxFor(o=>o.Q_PIC, new { @class = "budget-txt-no-01" })%></td>
        </tr>
        <tr>
            <td>项目名称</td>
            <td colspan="3"><%=Html.TextBoxFor(o => o.Q_PjName, new { @class = "budget-txt-no-01" })%></td>
            <td>项目代号</td>
            <td colspan="3"><%=Html.TextBoxFor(o => o.Q_PjCode, new { @class = "budget-txt-no-01" })%></td>
        </tr>
        <tr>
            <td colspan="8">                
                <input type="submit" value="查询" class="budget-button-no-01" />                
                仅显示无预算关联项目
                <%=Html.CheckBoxFor(o => o.Q_ShowNoRelation) %>
            </td>
        </tr>    
    </table>

    <br />
    <uc_PT:PageTool ID="ucPage" runat="server" />
    <br />

    <table border="0" cellpadding="0" cellspacing="0" class="List" id="QueryTable">
        <tr class="header">
            <td class="first">编制单位</td>
            <td>类别</td>
            <td>类型</td>
            <td>项目名称</td>
            <td>项目代号</td>
            <td>项目负责人</td>
            <td>经费来源</td>
            <td>项目周期-起</td>
            <td>项目周期-止</td>
            <td class="space">&nbsp;</td>
            <td>关联最新预算年度</td>
            <td>关联预算状态</td>
        </tr>

        <% if (Model.Table.Any()) { %>
        
            <% foreach (ProjectItem oItem in Model.Table) { %>
                <tr class="body" onclick="SelectPj(this)" Key='<%=oItem.Project.Guid %>' CanDelete='<%=oItem.Budget.Any() %>'>
                    <td class="first"><%=oItem.Department.DepartmentName %>&nbsp;</td>
                    <td><%=oItem.ProjectCategory.Name  %>&nbsp;</td>
                    <td><%=oItem.ProjcetType.Name  %>&nbsp;</td>
                    <td><%=oItem.Project.ProjectName %>&nbsp;</td>
                    <td><%=oItem.Project.ProjectCode%>&nbsp;</td>
                    <td><%=oItem.ProjcetPIC.UserName %>&nbsp;</td>
                    <td><%=oItem.Project.FundsSources %>&nbsp;</td>
                    <td><%=oItem.Project.ProjectBeginTime %>&nbsp;</td>
                    <td><%=oItem.Project.ProjectEndTime %>&nbsp;</td>
                    <td class="space">&nbsp;</td>
                    <td><%if (oItem.Budget.Any()) { %><%=oItem.Budget.First().Year %><% } %>&nbsp;</td>
                    <td><%if (oItem.Budget.Any()) { %><%=Model.BS.Where(o=>o.Status ==oItem.Budget.First().BudgetStatus).First().Name %><% } %>&nbsp;</td>
                </tr>
            <% } %>

        <% } %>

    </table>
    
    <input name="DeleteID" type="hidden" />
    <br />
    <input type="submit" value="删除" class="budget-button-no-01" onclick="return OnDelete()" style="display:none" id="btnDelete" />
    
    <% Html.EndForm(); %>
</asp:Content>
